package com.yn.front.zy;


import com.github.pagehelper.PageInfo;
import com.yn.common.page.BasePage;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.request.zy.OrganInfoAddRequest;
import com.yn.common.response.sc.BaseResult;
import com.yn.common.response.zy.OrganQueryResponse;
import com.yn.service.zy.TOrganInfoService;
import com.yn.service.zy.model.dto.TOrganInfoDTO;
import com.yn.service.zy.model.query.TOrganInfoQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("api/front/organ")
@Api(tags = "用户端机构信息接口")
@Slf4j
public class OrganInfoController {

    @Autowired
    private TOrganInfoService tOrganInfoService;

    /**
     * 分页查询机构信息列表
     * @param query 机构信息查询对象
     * @param pageRequest 分页参数
     * @return 机构信息列表
     */
    @ApiOperation("分页查询机构信息")
    @GetMapping("/listPage")
    public BaseResult<BasePage<OrganQueryResponse>> listPage(TOrganInfoQuery query, PageParamRequest pageRequest){
        log.info("分页查询机构信息入参:{}",query);
        PageInfo<OrganQueryResponse> page = tOrganInfoService.listPage(query, pageRequest);
        return BaseResult.success(BasePage.restPage(page));
    }


    /**
     * 机构信息详情
     * @param id 机构信息id
     * @return 机构信息详情
     */
    @ApiOperation("查询机构详细信息")
    @GetMapping("/getInfo")
    public BaseResult<TOrganInfoDTO> getInfo(@RequestParam @NotNull Integer id){
        log.info("查询机构详细信息入参:{}",id);
        TOrganInfoDTO info = tOrganInfoService.getInfo(id);
        return BaseResult.success(info);
    }

}
